package com.tzvtc.server.commons.bean;

import lombok.Data;

@Data
public class ResultBean {

    private Integer code;

    private String message;

    private Object data;

    public ResultBean(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static ResultBean success(Object data) {
        return new ResultBean(200, "执行成功", data);
    }

    public static ResultBean success(String message, Object data) {
        return  new ResultBean(200, message, data);
    }

    public static ResultBean success(Integer code, String message, Object data) {
        return new ResultBean(code, message, data);
    }


    public static ResultBean fail(Integer code, String message) {
        return new ResultBean(code, message, null);
    }

    public static ResultBean fail(String message) {
        return new ResultBean(500, message, null);
    }



    public static ResultBean fail() {
        return new ResultBean(500, "操作失败", null);
    }

    public static ResultBean fail(Integer code) {
        return new ResultBean(code, "操作失败", null);
    }

}
